package com.example.xiaosuan.ziyuanfuyongpingtai;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

public class qwe123 extends AppCompatActivity implements View.OnClickListener{
private TextView tv;
    private EditText et;
    private Button btngettext,btnsetimg;
    private ImageView iv;
    private ImageButton ibtn;
    //声明8个控件
    private RadioGroup rg;
    private RadioButton rbnan,rbnv;
    private CheckBox cblan,cbzu,cbyou;
    private  Button btngetgender,btngetfun;
    private String strfun;

    rg =(RadioGroup) findViewById(R.id.radiogroup);



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_qwe123);
        Intent intent = getIntent();
        final String str = intent.getStringExtra("vl1");
        int n = intent.getIntExtra("vl2", 10);
        //logcat中显示
        System.out.println("----" + str + "****" + String.valueOf(n));
        //toast中显示
        Toast.makeText(this, str + "****" + String.valueOf(n), Toast.LENGTH_SHORT).show();
        //界面textview中显示
        final TextView tv = (TextView) findViewById(R.id.textView4);
        tv.setText(str + "****" + String.valueOf(n));

        Button button = (Button) findViewById(R.id.button5);
        button.setOnClickListener(this);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.redioButton:
                        tv.setText("男");
                        break;
                    case R.id.redioButton1:
                        tv.setText("女");
                        break;
                }
            }


        });
        cblan.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    strfun+="篮球+";


                }else {
                    strfun=strfun.replace("篮球+","");
                    tv.setText(strfun);
                }
            }
        });
        cbzu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    strfun+="足球+";


                }else {
                    strfun=strfun.replace("足球+","");
                    tv.setText(strfun);
                }
            }
        });

        cbyou.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    strfun+="游泳+";


                }else {
                    strfun=strfun.replace("游泳+","");
                    tv.setText(strfun);
                }
            }
        });



    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button5:
                finish();
                break;
            case R.id.button7:
                String msg="";
                if(cblan.isChecked()) msg+="lanqui+";
                if(cbzu.isChecked()) msg+="zuqiu+";
                if(cbyou.isChecked()) msg+="youyong+";
                tv.setText(msg);
                break;
        }
    }
}
